package GUI;

import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.border.EmptyBorder;

public class Rent extends JFrame {

	private JPanel contentPane;
	private MainMenu main;
	private AddIorP aip;
	private AssignToOrder a;
	private Print p;
	private Success su;
	

	/**
	 * Create the frame.
	 */
	public Rent(String s) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 350, 430);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
	
		JButton btnAddProduct = new JButton("Add Product");
		btnAddProduct.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				aip = new AddIorP("p");
				aip.setVisible(true);
			}
		});
		btnAddProduct.setBounds(10, 30, 100, 22);
		contentPane.add(btnAddProduct);
		
		JButton btnMember = new JButton("Member");
		btnMember.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				a = new AssignToOrder("m","r");
				a.setVisible(true);
			}
		});
		btnMember.setBounds(10, 57, 100, 22);
		contentPane.add(btnMember);
		
		JButton btnPayment = new JButton("Payment");
		btnPayment.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				a = new AssignToOrder("p","r");
				a.setVisible(true);
			}
		});
		btnPayment.setBounds(10, 84, 100, 22);
		contentPane.add(btnPayment);
	
		JButton btnDelivery = new JButton("Delivery");
		btnDelivery.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				a = new AssignToOrder("del","r");
				a.setVisible(true);
			}
		});
		btnDelivery.setBounds(10, 111, 100, 22);
		contentPane.add(btnDelivery);
	
		JButton btnStaff = new JButton("Staff");
		btnStaff.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				a = new AssignToOrder("s","o");
				a.setVisible(true);
			}
		});
		btnStaff.setBounds(10, 139, 100, 22);
		contentPane.add(btnStaff);
	
		JTextArea txtStatusDisplay = new JTextArea();
		txtStatusDisplay.setFont(new Font("Monospaced", Font.PLAIN, 12));
		txtStatusDisplay.setTabSize(10);
		txtStatusDisplay.setText("ID:\r\nDate:\r\nStaff:\r\nMember:\r\nPayment Type:\r\nPayment due:\r\nDelivery:");
		txtStatusDisplay.setBounds(10, 201, 200, 148);
		contentPane.add(txtStatusDisplay);
	
		JButton btnCancel = new JButton("Cancel");
		btnCancel.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				MainMenu.getInstance().setVisible(true);
				dispose();
			}
		});
		btnCancel.setBounds(10, 360, 100, 22);
		contentPane.add(btnCancel);
	
		if(s.equals("new"))
		{
			JButton btnSave = new JButton("Save");
			btnSave.addMouseListener(new MouseAdapter() {
				@Override
				public void mouseClicked(MouseEvent e) {
					//???? SABIN
					su = new Success("cr", true);
					su.setVisible(true);
					dispose();
				}
			});
			btnSave.setBounds(224, 360, 100, 22);
			contentPane.add(btnSave);
		}
		else
		{
			JButton btnSave = new JButton("Save");
			btnSave.addMouseListener(new MouseAdapter() {
				@Override
				public void mouseClicked(MouseEvent e) {
					//???? SABIN
					su = new Success("mng", true);
					su.setVisible(true);
					dispose();
				}
			});
			btnSave.setBounds(224, 360, 100, 22);
			contentPane.add(btnSave);
			}
	
		JList list = new JList();
		list.setBounds(119, 33, 205, 157);
		contentPane.add(list);
		
		JTextPane txtpnTotal = new JTextPane();
		txtpnTotal.setText("Total: ");
		txtpnTotal.setBounds(220, 201, 104, 22);
		contentPane.add(txtpnTotal);
		
		JTextPane txtpnReturnDate = new JTextPane();
		txtpnReturnDate.setText("Return date:");
		txtpnReturnDate.setBounds(220, 234, 104, 22);
		contentPane.add(txtpnReturnDate);
	
		String n="new";
		if(s.equals(n)){setTitle("Create New Rental");}
		else{setTitle("Manage Rental");
		JLabel lblNewLabel = new JLabel("Rental ID:");//Display info!!!
		lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 14));
		lblNewLabel.setBounds(107, 10, 120, 14);
		contentPane.add(lblNewLabel);
		}
	}
}
